home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / turbocad_test3.vbs < prev    next >
Encoding:
Text File  |  2001-10-16  |  1.7 KB  |  113 lines

  1. 'Script to test for adding vertices to the selected graphic
  2.  
  3. Option Explicit
  4.  
  5. Dim tcApp
  6.  
  7. '================= Add Vertex the tail of collection
  8. Sub AddTail(tcVrts)
  9.  
  10. Dim tcVrt
  11. Dim cnt
  12. Dim X
  13. Dim Y
  14. Dim Z
  15.  
  16.     cnt = tcVrts.Count
  17.     
  18.     Set tcVrt = tcVrts(cnt - 1)
  19.     X = tcVrt.X + 1
  20.     Y = tcVrt.y + 1
  21.     z = tcVrt.z
  22.     
  23.     Set tcVrt = tcVrts.Add(x, y, z)
  24.  
  25.     MsgBox "Vertices count: " & CStr(tcVrts.Count) & " Vertex added to the " & CStr(tcVrt.Index)
  26.  
  27. end sub
  28.  
  29. '================= Add Vertex the head of collection
  30. Sub AddHead(tcVrts)
  31.  
  32. Dim tcVrt
  33.  
  34. Dim X
  35. Dim Y
  36. Dim Z
  37.  
  38.     Set tcVrt = tcVrts(0)
  39.  
  40.     X = tcVrt.X - 1
  41.     Y = tcVrt.y - 1
  42.     z = tcVrt.z
  43.     
  44.     Set tcVrt = tcVrts.Add(x, y, z, , , , , , , 0)
  45.  
  46.     MsgBox "Vertices count: " & CStr(tcVrts.Count) & " Vertex added to the " & CStr(tcVrt.Index)
  47.  
  48.  
  49. end sub
  50.  
  51. '================= Add Vertex the middle of collection
  52. Sub AddMiddle(tcVrts)
  53.  
  54. Dim tcVrt
  55.  
  56. Dim tcVrt0
  57. Dim tcVrt1
  58.  
  59. Dim X
  60. Dim Y
  61. Dim Z
  62.  
  63.     Set tcVrt0 = tcVrts(0)
  64.     Set tcVrt1 = tcVrts(1)
  65.  
  66.     X = (tcVrt1.X + tcVrt0.X) / 2
  67.     Y = (tcVrt1.y + tcVrt0.y) / 2
  68.     z = (tcVrt1.z + tcVrt0.z) / 2
  69.     
  70.     Set tcVrt = tcVrts.Add(x, y, z, , , , , , , , tcVrt0)
  71.  
  72.     MsgBox "Vertices count: " & CStr(tcVrts.Count) & " Vertex added to the " & CStr(tcVrt.Index)
  73.  
  74. end sub
  75.  
  76. Sub Main()
  77.  
  78. Dim cnt
  79. Dim tcSel
  80. Dim tcDwg
  81. Dim tcVrts
  82.  
  83.  
  84.  
  85.     Set tcSel = tcApp.Selection
  86.     cnt = tcSel.Count
  87.     MsgBox "Selection count: " & CStr(cnt)
  88.  
  89.     If (cnt <> 1) Then
  90.         Exit Sub
  91.     End If
  92.  
  93.     Set tcDwg = tcApp.ActiveDrawing
  94.     Set tcVrts = tcSel(0).Vertices
  95.  
  96.     AddTail tcVrts
  97.  
  98.     AddHead tcVrts
  99.  
  100.     AddMiddle tcVrts
  101.  
  102.     tcSel(0).Closed = False
  103.     tcSel(0).Select    
  104.     tcDwg.ActiveView.Refresh
  105. end sub
  106.  
  107.     Set tcApp = CreateObject("TurboCAD.Application")
  108.     tcApp.Visible = True
  109.  
  110.     Main
  111.  
  112.     MsgBox "Done"
  113.